<template>
  <div>
    <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item><a href="/">活动管理</a></el-breadcrumb-item>
    <el-breadcrumb-item>活动列表</el-breadcrumb-item>
    <el-breadcrumb-item>活动详情</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card class="box-card">
      <el-input placeholder="请输入内容" v-model="serachinfo" class="input-with-select">
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
<!--      添加用户-->
      <el-button type="primary">
        <span>添加用户</span>
      </el-button>
    </el-card>
    <el-table
      :data="userlist"
      border stripe
     >
      <el-table-column
        type="index"
        :index="indexMethod" label="#">
      </el-table-column>

      <el-table-column
        prop="username"
        label="姓名"
        >
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        >
      </el-table-column>
      <el-table-column
        prop="mobile"
        label="电话">
      </el-table-column>
      <el-table-column
        prop="role_name"
        label="角色">
      </el-table-column>
      <el-table-column
        prop="mg_state"
        label="状态">
      </el-table-column>
      <el-table-column
        prop="role_name"
        label="操作">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryInfo.pagenum"
      :page-sizes="[50, 100, 200]"
      :page-size="queryInfo.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return{
      queryInfo:{
        query:'',/*查询条件*/
        pagenum:1,/*查询页码*/
        pagesize:50/*页码的大小*/
      },
      total:0,
      /*返回的用户列表参数*/
      userlist:[]

    }
  },
  created() {
    this.getUserList();
    this.activePath=window.sessionStorage.getItem('activePath')
  },
  methods:{

    //请求用户列表
    async getUserList(){
        const {data:res}=await  this.$http.get("users",{params:this.queryInfo});
        if (res.meta.status!==200) return this.$message.error('获取用户列表失败');
        this.userlist=res.data.users;
        this.total=res.data.total;
        console.log('userlist'+this.userlist);
        console.log('data'+res);

    },
    handleSizeChange(pagesize){
      this.queryInfo.pagesize=pagesize;
      this.getUserList();
    },
    handleCurrentChange(currentPage){
      this.queryInfo.pagenum=currentPage;
      this.getUserList();
    }
  }
}
</script>

<style lang="less" scope>
.el-input{
  width: 300px;
}
</style>
